<?php

namespace application\home\controller;

use ticky\controller;
use ticky\config;

class auth extends controller {

    public $uid = 0;
    public $siteid = 0;
    public $username = '';
    public $groupid = 0;
    public $ip = '';

    public function __construct() {
        if (!file_exists(RUNTIME_PATH . './install.lock')) {
            header('location: install.php');
            exit;
        }

        if (isset($_GET['siteid'])) {
            $this->siteid = intval($_GET['siteid']);
        } else {
            $this->siteid = get_siteid();
        }

        $this->uid = session('uid');
        $this->username = session('username');
        $this->groupid = session('groupid');
        $this->ip = \ticky\request::getClientIp();

        $this->assign('siteid', $this->siteid);
        $this->assign('uid', $this->uid);
        $this->assign('username', $this->username);
        $this->assign('groupid', $this->groupid);

        //设置模板
        $site_theme = get_siteinfo($this->siteid)['template'];
        if (!empty($site_theme)) {
            config::set('view', ['default_theme' => $site_theme]);
        }
    }

}
